#include <string.h>

#include "base/string_wrapper.h"

#include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h"

using namespace base;

class StringWrapperTest : public CppUnit::TestFixture {
    CPPUNIT_TEST_SUITE(StringWrapperTest);
    CPPUNIT_TEST(testComparisons);
    CPPUNIT_TEST_SUITE_END();

public:
    void setUp() {
    }

    void tearDown() {
    }

    void testComparisons() {
        char* hello_basic = "hello";
        std::string hello_string(hello_basic);
        StringWrapper hello_wrapper_basic(hello_basic);
        StringWrapper hello_wrapper_string(hello_string);

        CPPUNIT_ASSERT(hello_basic == hello_string);
        CPPUNIT_ASSERT(hello_string == hello_basic);
        CPPUNIT_ASSERT(hello_basic == hello_wrapper_basic);
        CPPUNIT_ASSERT(hello_wrapper_basic == hello_basic);
        CPPUNIT_ASSERT(hello_string == hello_wrapper_basic);
        CPPUNIT_ASSERT(hello_wrapper_basic == hello_string);
        CPPUNIT_ASSERT(hello_wrapper_basic == hello_wrapper_string);
        CPPUNIT_ASSERT(hello_wrapper_string == hello_wrapper_basic);

        CPPUNIT_ASSERT(!(hello_basic != hello_string));
        CPPUNIT_ASSERT(!(hello_string != hello_basic));
        CPPUNIT_ASSERT(!(hello_basic != hello_wrapper_basic));
        CPPUNIT_ASSERT(!(hello_wrapper_basic != hello_basic));
        CPPUNIT_ASSERT(!(hello_string != hello_wrapper_basic));
        CPPUNIT_ASSERT(!(hello_wrapper_basic != hello_string));
        CPPUNIT_ASSERT(!(hello_wrapper_basic != hello_wrapper_string));
        CPPUNIT_ASSERT(!(hello_wrapper_string != hello_wrapper_basic));

        CPPUNIT_ASSERT(hello_basic <= hello_wrapper_basic);
        CPPUNIT_ASSERT(hello_basic >= hello_wrapper_basic);
        CPPUNIT_ASSERT(!(hello_basic < hello_wrapper_basic));
        CPPUNIT_ASSERT(!(hello_basic > hello_wrapper_basic));
    }
};

CPPUNIT_TEST_SUITE_REGISTRATION(StringWrapperTest);